<template>
  <van-empty v-if="userList.length === 0" description="暂无匹配用户！" />
  <card-user-list :userList="userList" />
</template>

<script setup>
import {useRoute} from "vue-router";
import {onMounted, ref} from "vue";
import request from "../request/request";
import qs from 'qs'
import CardUserList from "../components/CardUserList.vue";


const route = useRoute();

const {tagList} = route.query

const userList = ref([])

onMounted(async () => {
  await request.get('/user/search/tag', {
    params: {
      tagNameList: tagList
    },
    paramsSerializer: (params) => {
      return qs.stringify(params, {indices: false})
    }
  }).then(resp => {
    if (resp.data.code === 200) {
      let userListData = resp.data.data;
      userList.value = userListData.map(user => {
        user.userTags = JSON.parse(user.userTags)
        return user;
      });
    }

  }).catch(error => {
    console.log(error);
  })
})


</script>

<style scoped>

</style>